package com.jeeplus.modules.gen;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;

import com.jeeplus.common.utils.PropertiesLoader;
import com.jeeplus.modules.gen.util.RSA;

public class Creak {
	public static boolean kill = false;
	private static PropertiesLoader a6 = new PropertiesLoader(new String[]{"/properties/license.properties"});
	
	private static final String publicKey ="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCNb6CzrCOqm+R/UQC0FlA2n5v1zoIoAKoct3GmKqkTpP6XJ7Jzy9axG7JhgELwYOWmk4Py6lUI1D4VHi8ZCBk+I785MWeMDFi+kxX4S66YBhZV+/onfKnO2lfNdGkNfZpOFYJH6NOrAN5Q0UxVkSc12PWW4OdkLbBSk/34/4IQJQIDAQAB";
	private static final String privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAI1voLOsI6qb5H9RALQWUDafm/XOgigAqhy3caYqqROk/pcnsnPL1rEbsmGAQvBg5aaTg/LqVQjUPhUeLxkIGT4jvzkxZ4wMWL6TFfhLrpgGFlX7+id8qc7aV810aQ19mk4Vgkfo06sA3lDRTFWRJzXY9Zbg52QtsFKT/fj/ghAlAgMBAAECgYAuse0HhMydtixBUHf//OHsttNh2xUjqdx/8Jyn9KuvnaikNOn4yxKNlIxXHmZ7QDJxxYApwe3jJVd912JLTF4woDu6fRA9RSySh4Nc9MLnr6bs45qzJ4Qo5fexdwnNBaEx1Y0obTcvoSdxaQb9V7sN/43cksh8QpJkWkF5Lp6OPQJBAPusmRyMl5adCyAmWbnf5yTPdZj4W9sNwoTnfbtqtQHc/Dawza4mddeC96Y5JrE7lhdAaAjnJByKuvXHAEuXousCQQCP3fdai+p+KL6OzPiSKfpoHTwZUyPzlj7skYF3PgXDftr6UKG6/qVzexj8+W7mEXDlee3MQ2rrmPaC8erMsbUvAkEAri3lBcIzw5RKt+Ry4taYVXyTSdxRTki2oF7KQOR4A6MalwtEPkv18MJ+fPc+1RiFJvB3T/oQnwRQonsotChtIwJAYmDHt5w74r9b52yUgebAvBdZtHuc9wIDz2OEo5S+/jst5MPkhGmDnB9OLBcpVZwRlmo1SVvEroyv7UUeaZEPswJBAJqxUSZLzU97wNHV/IlRYh3nr41h8G9+miIyluRlp0kVfZ3sJFx5Kf+Bun/EWZCow+8C9G3onh0KfjAbhQC+8l4=";	
	public  static void k()
	{	kill = true;
		String license = a6.getProperty("license");
		byte[] encWord;
		try {
			encWord = RSA.decodeBase64(license);
			String decWord = new String(RSA.decryptByPrivateKey(encWord, privateKey));
		if(decWord.equals(getMC())){
			kill = true;
		}
		
		if(decWord.equals(getLocalMac())){
			kill = true;
		}
		
		if(decWord.startsWith("QAZWSXEDC")){
		Long time =	Long.valueOf(decWord.substring("QAZWSXEDC".length()));
			if(time>System.currentTimeMillis()){
				kill = true;
			}
		}
		
		
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		String str = "QAZWSXEDC123456789";
		System.out.println(str.substring("QAZWSXEDC".length()));
		  PropertiesLoader as6 = new PropertiesLoader(new String[]{"/properties/license.properties"});
	}
	
	public  static String getMC() throws Exception{
		InetAddress e = InetAddress.getLocalHost();
	      byte[] var6 = NetworkInterface.getByInetAddress(e).getHardwareAddress();
	      StringBuffer a4 = new StringBuffer();

	      for(int i = 0; i < var6.length; ++i) {
	          if(i != 0) {
	              a4.append("D");
	          }

	          String a3 = Integer.toHexString(var6[i] & 255);
	          a4.append(a3.length() == 1?0 + a3:a3);
	      }
	      	return a4.toString().toUpperCase();
	}
	
	
	private static String getLocalMac() throws SocketException {
		// TODO Auto-generated method stub
		//获取网卡，获取地址
		byte[] mac;
		try {
			mac = NetworkInterface.getByInetAddress(InetAddress.getLocalHost()).getHardwareAddress();
			StringBuffer sb = new StringBuffer("");
			for(int i=0; i<mac.length; i++) {
				if(i!=0) {
					sb.append("-");
				}
				//字节转换为整数
				int temp = mac[i]&0xff;
				String str = Integer.toHexString(temp);
				if(str.length()==1) {
					sb.append("0"+str);
				}else {
					sb.append(str);
				}
			}
			return sb.toString().toUpperCase();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return "ASDFGHJKLQWERTYUIOPZXCVBNM";
	}
}
